package com.ljf.authority.infra.repository.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ljf.authority.domain.repository.AuthorityBaseButtonDetailRepository;
import com.ljf.authority.dto.query.AuthorityBaseButtonDetailQuery;
import com.ljf.authority.infra.mapper.AuthorityBaseButtonDetailMapper;
import com.ljf.authority.model.AuthorityBaseButtonDetail;
import com.ljf.authority.vo.AuthorityBaseButtonDetailVO;
import com.ljf.common.exception.ServiceException;
import com.ljf.common.infra.repository.impl.BasisRepositoryImpl;
import com.ljf.common.utils.CollectionUtil;
import com.ljf.common.utils.StringUtil;
import org.springframework.stereotype.Component;

/**
 * 按钮明细  数据访问接口实现
 *
 * @author LJF
 * @since 2024-10-20
 */
@Component
public class AuthorityBaseButtonDetailRepositoryImpl extends BasisRepositoryImpl<AuthorityBaseButtonDetailMapper, AuthorityBaseButtonDetail, AuthorityBaseButtonDetailQuery, AuthorityBaseButtonDetailVO> implements AuthorityBaseButtonDetailRepository {

    @Override
    protected QueryWrapper<AuthorityBaseButtonDetail> fillWrapper(AuthorityBaseButtonDetailQuery query, boolean sort) throws ServiceException {
        QueryWrapper<AuthorityBaseButtonDetail> wrapper = super.fillWrapper(query, sort);
        if (CollectionUtil.isNotEmpty(query.getCodeList())) {
            wrapper.in(AuthorityBaseButtonDetail.COL_CODE, query.getCodeList());
        }
        if (StringUtil.isNotEmpty(query.getCodeRightLike())) {
            wrapper.likeRight(AuthorityBaseButtonDetail.COL_CODE, query.getCodeRightLike());
        }
        return wrapper;
    }

}
